
#include "iremote_proxy.h"
#include "i_onstatus_reverse.h"

namespace OHOS {
namespace Storage {
namespace DistributedFile {
class RemoteMountDfsProxy : public IRemoteProxy<IRemoteMountDfs> {
public:
    explicit RemoteMountDfsProxy(const sptr<IRemoteObject> &impl) : IRemoteProxy<IRemoteMountDfs>(impl)
    {}

    /**
     * @brief When the remote device disconnect, AbilityMs notify the listener.
     *
     * @param deviceId, remote device Id.
     * @param state, device state.
     */
    virtual void OnStatusNotify(const std::string& deviceId, uint8_t state) override;

private:
    static inline BrokerDelegator<RemoteMountDfsProxy> delegator_;
    int32_t SendTransactCmd(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option);

public:
    RemoteMountDfsProxy();
private:
    class ReverseDeathRecipient : public IRemoteObject::DeathRecipient {
    public:
        ReverseDeathRecipient(){};
        ~ReverseDeathRecipient() = default;
        using RemoteDiedHandler = std::function<void(const wptr<IRemoteObject> &)>;
        void SetDeathRecipient(RemoteDiedHandler handler);
        void OnRemoteDied(const wptr<IRemoteObject> &remote) override;

    private:
        RemoteDiedHandler handler_{ nullptr };
    };
private:
    static inline sptr<ReverseDeathRecipient> deathRecipient_;
};

} // namespace DistributedFile
} // namespace Storage
} // namespace OHOS